<template>
	<view class="mainPage">
		<!-- <view class="tip">转出消费券将收取3%的手续费</view> -->
		<view class="form-box">
			<view class="form-li">
				<view class="form-label">接收用户：</view>
				<view class="form-input"><u-input v-model="inRealName" type="number" placeholder="输入接收者手机号"
						:custom-style="customStyle" /></view>
			</view>
			<view class="form-li">
				<view class="form-label">转出分红积分：</view>
				<view class="form-input"><u-input v-model="amount" :type="type" placeholder="请输入分红积分"
						:custom-style="customStyle" /></view>
			</view>

			<view class="tip-two">当前可用分红积分： {{rewardIntegral}}</view>
		</view>
		<view class="btn" @tap="sureSubmit">确定</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				activateFee: "",
				user_info: {},
				type: 'number',
				mhbPointsFee: "",
				customStyle: {
					'font-size': '28rpx'
				},
				
				inRealName: "",
				amount: "",
				rewardIntegral: 0,
				walletType:""
			}
		},
		onLoad(option) {
			this.user_info = uni.getStorageSync('userInfo');
			
		},
		onShow() {
               this.getWalletCoupons();//获取消费券钱包 
		},
		methods: {
			getWalletCoupons(){
				let that=this;
				this.$u.post('zpuserwallet/wallets',{walletType:""}).then(res => {
					console.log(res)
					if(res.length>0){
						res.map((item)=>{
							if(item.walletType=="RED_INTEGRAL"){
								that.rewardIntegral=item.currentAmount;
							}
						})
					}
					
					
				});
			},
			sureSubmit() {
				if (this.inRealName == "") {
					uni.showToast({
						title: '请输入转入者手机号',
						icon:"none",
						duration: 2000
					});
					return
				}
				if (this.amount == 0 || this.amount == "") {
					uni.showToast({
						title: '请输入转出积分数',
						icon:"none",
						duration: 2000
					});
					return
				}
				this.$u.post('zpuserwallet/transfer', {
					inRealName: this.inRealName,
					amount: this.amount,
					walletType:"RED_INTEGRAL"
				}).then(res => {
					uni.showToast({
						title: '转出成功'
					})
				});
			}
		}
	}
</script>

<style lang="scss">
	.mainPage {
		background-color: #efefef;
		height: calc(100vh - 44px);
        padding-top: 20rpx;
		.tip {
			padding-top: 20rpx;
			padding-bottom: 20rpx;
			padding-left: 30rpx;
			padding-right: 30rpx;
			background-color: #f5b8c3;
			color: #E42548;
			font-size: 28rpx;
			font-weight: bold;
		}

		.form-box {
			margin-left: 30rpx;
			margin-right: 30rpx;
			background-color: #fff;
			border-radius: 20rpx;
			padding: 20rpx;
			margin-top: 20rpx;

			.form-li {
				display: flex;
				flex-direction: row;
				justify-content: flex-start;
				border-bottom: 2rpx solid #eee;

				.form-label {
					line-height: 70rpx;
				}
			}

			.tip-two {
				font-size: 24rpx;
				margin-top: 20rpx;
			}

			.input-box {
				border-bottom: 2rpx solid #efefef;
				margin-bottom: 20rpx;
			}
		}

		.btn {
			padding-top: 20rpx;
			padding-bottom: 20rpx;
			margin-left: 30rpx;
			margin-right: 30rpx;
			padding-right: 30rpx;
			background: linear-gradient(to right, #FFA858, #E42548);
			color: #fff;
			text-align: center;
			border-radius: 20rpx;
			margin-top: 20rpx;
		}
	}
</style>